<?php
require_once('../connection.php');

if(isset($_GET['userid']))
{
	$sql = 'SELECT * FROM `proposition` WHERE uid = :userid';
	$sth = $db->prepare($sql);
	$sth->bindParam(":userid",$_GET['userid']);
	$sth->execute();
	$res = $sth->fetchAll();
	echo json_encode($res);
} else if(isset($_GET['rid'])) {
    $sql = 'SELECT * FROM `proposition` WHERE rid = :rid';
	$sth = $db->prepare($sql);
	$sth->bindParam(":rid",$_GET['rid']);
	$sth->execute();
	$res = $sth->fetchAll();
	echo json_encode($res);
}
else {
	$sql = 'SELECT * FROM `proposition`';
	$sth = $db->prepare($sql);
	$sth->execute();
	$res = $sth->fetchAll();
	echo json_encode($res);
}
?>